﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using XiangDongClub.Common;

namespace XiangDongClub.Activity
{
    /// <summary>
    /// 用户是否单点登录
    /// </summary>
    [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, Inherited = true, AllowMultiple = true)]
    public class PowerFilter : FilterAttribute, IAuthorizationFilter
    {
        public void OnAuthorization(AuthorizationContext filterContext)
        {
            if (string.IsNullOrEmpty(CookieHelper.GetCookie("AuthPhone")))
            {
                filterContext.RequestContext.HttpContext.Response.Redirect("~/Home/GetPhoneByAuth?back=" + HttpContext.Current.Request.Url.AbsoluteUri);
            }
        }
    }
}